package cn.tedu.zhyl.appointment.mapper;

import cn.tedu.zhyl.appointment.pojo.dto.ReservationParam;
import cn.tedu.zhyl.appointment.pojo.entity.Reservation;
import cn.tedu.zhyl.appointment.pojo.vo.ReservationVO;
import cn.tedu.zhyl.appointment.pojo.vo.TimeCountVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ReservationMapper {
    void insert(Reservation reservation);

    List<ReservationVO> findByPage(Integer status);

    Integer getCancelledCount();

    List<TimeCountVO> getCountByTime(@Param("start") LocalDateTime start,@Param("end") LocalDateTime end);

    @Update("update reservation set status = #{status} where id = #{id}")
    void updateStatusById(@Param("id") Long id,@Param("status") Integer status);

    @Update("update reservation set status = 3 where status = 0 and `time` < #{now}")
    void updateReservation(LocalDateTime now);

    List<ReservationVO> selectList(ReservationParam requestParam);
}
